package guoanmaker.personal.business.repository;

import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import guoanmaker.personal.business.model.PersonalIpstatistics;
import guoanmaker.personal.business.model.PersonalUserstatistics;


public interface PersonalUserstatisticsRepository extends  JpaRepository<PersonalUserstatistics, String>, JpaSpecificationExecutor<PersonalUserstatistics> {
	
	@Query("select p from PersonalUserstatistics p where p.userid=:userid and date_format(p.createdate,'%y-%m-%d')=date_format(now(),'%y-%m-%d')")
	List<PersonalUserstatistics> selectUserstatisticsByUserid(@Param("userid")String userid);
	
	@Query("select p from PersonalUserstatistics p where p.type=:type and date_format(p.createdate,'%y-%m-%d')=date_format(now(),'%y-%m-%d')")
	List<PersonalUserstatistics> selectUserstatisticsByType(@Param("type")int type);
	
	@Query("select p from PersonalUserstatistics p where p.type=:type and p.commdityid=:commdityid and date_format(p.createdate,'%y-%m-%d')=date_format(now(),'%y-%m-%d')")
	List<PersonalUserstatistics> selectUserstatisticsByCommdityid(@Param("type") int type,@Param("commdityid") String commdityid);
	
}
